package com.uflower.user.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 用户表
 * 
 * @author bridge
 * @email bridgezrq@163.com
 * @date 2022-01-15 14:57:31
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("uf_user")
public class UserEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 编号
	 */
	@TableId
	private Long id;
	/**
	 * 用户名
	 */
	private String username;
	/**
	 * 密码
	 */
	private String password;
	/**
	 * 电话
	 */
	private String phone;
	/**
	 * 昵称
	 */
	private String nickname;
	/**
	 * 邮箱
	 */
	private String email;
	/**
	 * 生日
	 */
	@DateTimeFormat(pattern ="yyyy-MM-dd")
	private Date birthday;
	/**
	 * 性别
	 */
	private Integer gender;
	/**
	 * 头像
	 */
	private String header;
	/**
	 * 启用状态
	 */
	private Integer status;
	/**
	 * 注册时间
	 */
	@DateTimeFormat(pattern ="yyyy-MM-dd")
	private Date createTime;


	public UserEntity(String json) throws JsonProcessingException {
		UserEntity param = new ObjectMapper().readValue(json, UserEntity.class);
		this.id = param.getId();
		this.username = param.getUsername();
		this.password = param.password;
		this.phone = param.getPhone();
		this.nickname = param.nickname;
		this.email = param.getEmail();
		this.birthday = param.getBirthday();
		this.gender = param.gender;
		this.header = param.getHeader();
		this.status = param.getStatus();
		this.createTime = param.getCreateTime();
	}
}
